-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(timestamp): toMicros() should work for all timestamps fitting in bigint #11774
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for meta-velox canceled.
|
966f563
to
09a1ee4
Compare
86b1e46
to
eb494af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
velox/type/Timestamp.h
Outdated
|
||
// If the final result does not fit in int64_t we throw. | ||
__int128_t result = | ||
(__int128_t)seconds_ * 1'000'000 + (int64_t)(nanos_ / 1'000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use static_cast
to avoid C-style casts. See 28c319e.
@laithsakka @kagamiori Would you please help review this fix similar to |
As #7506, toMicros() throws because the computation overflows when multiplying
negative number then add positive number. In this case the final result still
fits in int64_t. This PR fixes this issue by using int128_t to make sure the
computation does not overflows.